/*
 * Copyright 2014 Cungmua, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cungmua.vn.kiosk.activity;

import com.androidquery.AQuery;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;
import cungmua.vn.kiosk.AbstractActivity;
import cungmua.vn.kiosk.R;
import cungmua.vn.kiosk.db.DatabaseHandler;
import cungmua.vn.kiosk.model.NhanVien;

/**
 * @author kelvin.nguyen
 * 
 */
public class NhanVienDetailActivity extends AbstractActivity {
	private DatabaseHandler db;
	private TextView txt_full_name;
	private TextView txt_id;
	private TextView txt_tuyen;
	private TextView txt_dienthoai;
	private ImageView iv_avatar;
	private NhanVien nhanvien;
	private AQuery aq;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_nhanvien_detail);
		db = new DatabaseHandler(self);
		aq = new AQuery(self);
		nhanvien = db.getAllNhanviens().get(0);
		initview();

	}

	public void initview() {
		iv_avatar = (ImageView) findViewById(R.id.iv_avatar);
		txt_full_name = (TextView) findViewById(R.id.txt_full_name);
		txt_id = (TextView) findViewById(R.id.txt_id);
		txt_tuyen = (TextView) findViewById(R.id.txt_tuyen);
		txt_dienthoai = (TextView) findViewById(R.id.txt_dienthoai);

		// set data for view
		if (nhanvien != null) {
			txt_full_name.setText(nhanvien.getName());
			txt_id.setText("ID " + nhanvien.getId());
			txt_dienthoai.setText("Điện thoại: " + nhanvien.getMobile());
			txt_tuyen.setText("Tuyen Q1.1");
			if (nhanvien.getImageUrl() != null) {
				aq.id(iv_avatar).image(nhanvien.getImageUrl(), true, true, 0,
						R.drawable.img_user);
			}
		}
	}
}
